package cm367;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;

@ManagedBean
@SessionScoped
public class RequestService implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private List<SelectItem> titleType;

	@ManagedProperty(value="#{userService}")
	private UserService userService;
	
	public RequestService() {
		
		titleType = new ArrayList<SelectItem>();
		titleType.add(new SelectItem("Mr."));
		titleType.add(new SelectItem("Mrs."));
		titleType.add(new SelectItem("Ms."));
		titleType.add(new SelectItem("Miss"));
		titleType.add(new SelectItem("Company"));

	}

	
	public boolean nameExists(String name) {
		if (userService.findUserByName(name)==null)
			return false;
		else
			return true;
	}


	public List<SelectItem> getTitleType() {
		return titleType;
	}


	public void setTitleType(List<SelectItem> titleType) {
		this.titleType = titleType;
	}


	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}	
	
}
